package com.turing.usdtpay.adapter;

import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.text.Html;

import com.turing.usdtpay.mvp.fragment.OrderListFragment;
import com.turing.usdtpay.utils.LogUtils;

import java.util.List;

/**
 * @作者：JAY
 * @创建时间：2019/10/12 18:00
 * @描述：
 **/
public class PagerAdapter extends FragmentPagerAdapter {
    private String TAG = "PagerAdapter";
    //添加fragment的集合
    private List<OrderListFragment> mFragmentList;
    //添加标题的集合
    private List<String> mTitleList;
    private List<String> mCountList;
    public PagerAdapter(FragmentManager fm,List<OrderListFragment> fragmentList,List<String> titleList,List<String> countList) {
        super(fm);
        mFragmentList = fragmentList;
        mTitleList = titleList;
        mCountList = countList;
    }

    @Override
    public Fragment getItem(int position) {
        return mFragmentList.get(position);
    }

    @Override
    public int getCount() {
        return mFragmentList.size();
    }

    public void updateTitle(List<String> titleList,List<String> countList){
        mTitleList = titleList;
        mCountList = countList;
        notifyDataSetChanged();
    }

    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {
        String title = mTitleList.get(position)+"<font color='#ff0000'>("+mCountList.get(position)+")</font>";
        return Html.fromHtml(title);
    }
}
